package com.hzky.demo.dao;

import com.hzky.demo.model.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Created by admin on 2017/6/6.
 */
public interface StudentDao extends JpaRepository<Student, Integer> {
    @Query(value = "SELECT d.* from child_english.dbo.homework a,child_english.dbo.student d,child_english.dbo.parents_course e where a.id=:homeworkId and e.course_id=a.course_id and e.p_number=d.parent_number",nativeQuery = true)
    List<Student> getStudentsByHomeworkId(@Param("homeworkId") Integer id);

    @Query(value = "select a.* from child_english.dbo.student a,child_english.dbo.homework_upload b where b.homework_id=:homeworkId and b.student_id=a.id",nativeQuery = true)
    List<Student> getFinishStudentsByHomeworkId(@Param("homeworkId") Integer id);
}
